export const splitStrFn = (str: string, num: number) => {
  if (!str) {
    return " "
  }

  if (str.length <= num) {
    return str; // 如果字符串长度小于等于间隔，不添加换行符
  }

  let result = "";
  for (let i = 0; i < str.length; i++) {
    if (i > 0 && i % num === 0) {
      result += "\n";
    }
    result += str[i];
  }

  return result;
}


export const splitFileNameStr = (str: string) => {
  if (!str.length) return false;

  console.log(str);


  const regex = /\/([^\/]+\.\w+)/g;
  const matches: any = str.match(regex);


  if (matches.length) {
    const fileNameWithExtension = matches[0].replace('/', '');
    return fileNameWithExtension
  } else {
    return str
  }




  // const fileNameWithExtension = matches[0].replace('/', '');

  // console.log(fileNameWithExtension);


  // if (matches) {
  //   console.log(matches, 222);

  //   for (var i = 0; i < matches.length; i++) {

  //     console.log(fileNameWithExtension);
  //   }
  // }
}

